<?php

namespace App\Jobs;

use App\Models\Refund;

class QueryRefund extends BaseJob
{
    public string $queue = 'payment';

    public function __construct(protected Refund $refund)
    {
        $this->delay(120);
    }

    public function handle(): void
    {
        $payment = $this->refund->order->payment->init();

        $response = $payment->getClient()->get('v3/refund/domestic/refunds/'.$this->refund->no);

        $this->refund->refunded($response->toArray());
    }
}
